# extends texmath

snippet class "classdef ... end" 	bA
classdef ${1:`!p snip.rv = snip.basename`} < ${2:baseName} % {{{
	properties
		$0
	end % properties

	methods
		function self = ${1}(${3:varargin})
			[optional, kwargs] = parseArguments($3);
			${5:self@$2($3{:})}
		end % function
	end % methods
end % classdef }}}
endsnippet

snippet prop "properties ... end" bA
% Property: ${1:name} {{{
properties 
	$1
end % properties }}}

$0
endsnippet

snippet meth "methods" bA
% Methods: ${1:name} {{{
methods 
end % methods }}}
endsnippet

snippet func "function [varargout] = XXX(varargin)... end" b
function [${3:varargout}] = ${1:name}(${2:varargin})  % {{{
	$0
end % function $1 % }}}

endsnippet

snippet functest "function testXXX(testCase)... end" bA
function [testCase] = test${1:name}(testCase)  % {{{
	${0}
end % function $1 % }}}

endsnippet

snippet functiontest "function tests = testXXX() ... end" b
%> @breif ${4:Documentation for function $1.} {{{
%>
%> @param(in) $2:
%> 
%> @return $3 : 
%>
function [${3:`!p
if snip.basename[:4] == 'test':
	snip.rv = 'tests'
else:
	snip.rv = 'varargout'
`}] = ${1:`!p snip.rv = snip.basename`}${2:`!p
if snip.basename[:4] == 'test':
	snip.rv = ''
else:
	snip.rv = '(varargin)'
`}
	${0:tests = functiontests(localfunctions);}
end % function $1
% }}}
${5:`!p
if snip.basename[:4] != 'test':
	snip.rv = ''
else:
	snip.rv = '''
function setup(testCase)
	
end % function setup
function teardown(testCase)
	
end % function teardown
'''
`}
endsnippet

snippet dprop "dependent property" bA
% Property: ${1:name} {{{
properties (Dependent)
	$1
end % properties

methods 
	function value = get.$1(self)
		value = get$1(self);
	end % function 

	function set.$1(self, value)
		set$1(self, value);
	end % function 
end % methods

methods (Access = protected)
	function value = get$1(self)
		value = self.${2:`!p snip.rv = t[1].lower()`};
	end % function 

	function set$1(self, value)
		${3:self.$2 = value;}
	end % function 
end % methods
% }}}

$0
endsnippet

snippet priv "private" wA
(Access = private)
endsnippet

snippet prot "protected" wA
(Access = protected)
endsnippet

snippet Ab "abstract" wA
Abstract
endsnippet

snippet if "if ... end" b
if ${1:Condition} % {{{
	$0
end % if }}}
endsnippet

snippet ife "if ... else ... end" b
if ${1:Condition} % {{{
	$2
else 
	$3
end % if }}}
endsnippet

snippet try "try ... catch ... end"
try % {{{
	$1
catch ${2:e}
	throw $2;
end % try }}}
endsnippet

snippet fdoc "documentation" 
% ${1:description}
% 
% Parameters:
% 
% Return: 
% 
%% Code: 
endsnippet

snippet parseArguments "parseArguments" 
[optional, kwargs] = parseArguments(varargin{:});
keys = fieldnames(kwargs);
for i = 1:numel(keys)
	name = keys{i};
	self.(name) = kwargs.(name);
end % for
endsnippet

